package org.fuxia.im.listeners;

import javax.swing.JFrame;
import javax.swing.SwingUtilities;

import org.fuxia.im.core.entries.ECPacket;
import org.fuxia.im.core.listeners.Listener;
import org.fuxia.im.gui.GroupApplyHandler;

/**
 * 处理申请加入群组结果
 *
 */
public class HandlerAddGroupApplyListener implements Listener {

	public void trigger(Object param) {
		final ECPacket packet = (ECPacket) param ;
		
		
		SwingUtilities.invokeLater(new Runnable() {
			
			public void run() {
				String groupId = packet.getParameter("groupId") ;
				String groupName = packet.getParameter("groupName") ;
				String userCode = packet.getParameter("userCode") ;
				String nickName = packet.getParameter("nickName") ;
				String extraInfo = packet.getParameter("extraInfo") ;
				GroupApplyHandler gah = new GroupApplyHandler() ;
				gah.putProperties("packet", packet);
				gah.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE) ;
				gah.setBounds(100, 100, 346, 285);
				gah.setResizable(false);
				gah.insertApplyMessage(String.format("%s(%s)", nickName,userCode),String.format("%s(%s)", groupName,groupId)) ;
				gah.insertExtraInfo(extraInfo) ;
				gah.setVisible(true);
			}
		});
		
	}

}
